<template>
  <view>
    <page-meta :page-style="themeColor"></page-meta>

    <view class="u-text-center" v-if="type != 3">
      <image style="margin-top: 120rpx !important;" src="https://runshui.oss-cn-shenzhen.aliyuncs.com/images/common/logo.pngPWB6.png" mode="widthFix">
      </image>
      <!-- <view class="u-font-40 u-text-bold u-m-t-30">{{ noticeData.value }}</view> -->
      <!-- <view class="u-font-40 u-text-bold u-m-t-10">{{ noticeData.value1 }}</view> -->
      <view class="u-font-40 u-text-bold u-m-t-10">桶装水订购及预约请点击</view>
      <view class="u-m-t-10" style="display: flex;
    justify-content: center;">
        <view style="margin-top: 40rpx !important;;" class="call_btn" @click="jump()">水润天下订水商城</view>
      </view>
      <view class="u-color-gray u-font-30 u-text-bold " style="margin-top: 120rpx !important;">如有其他需要请联系客服：</view>
      <view class="u-color-blue u-font-40 u-m-t-10 u-text-bold">{{ noticeData.value2 }}</view>
      <view class="u-color-blue u-m-t-10 u-font-26">{{ noticeData.content }}</view>
      <view class="call_btn" style="margin-top: 40rpx !important;" @click="callCustom()">拨打客服电话</view>
    </view>
  </view>
</template>

<script>
export default {
  components: {
  },
  data() {
    return {
      noticeData: {},
      type: 3
    }
  },
  onLoad() {
    this.$api.sendRequest({
      url: '/api/member/judgeUserOld',
      success: res => {
        console.log(res, '/api/member/judgeUserOld');
        this.type = res.data
        this.userJudge()
      }
    })
  },
  methods: {
    jump() {
      uni.navigateToMiniProgram({
        shortLink: '#小程序://润天下订水商城丨桶装水到家/mkq0TQ9kTh66qgb'
      })
    },
    userJudge() {
      if (this.type) {
        this.$api.sendRequest({
          url: '/api/member/getConfig',
          data: {
            key: 'temp'
          },
          success: res => {
            console.log(res, '/api/member/getConfig');
            this.noticeData = res.data
          }
        })
      } else {
        this.$util.redirectTo('/pages/index/index');
      }
    },
    call(mobile) {
      const res = uni.getSystemInfoSync()
      if (res.platform == 'ios') {
        uni.makePhoneCall({
          phoneNumber: mobile,
          success: () => { },
          fail() { }
        })
      } else {
        uni.showActionSheet({
          itemList: [mobile, '呼叫'],
          success: (res) => {
            if (res.tapIndex == 1) {
              uni.makePhoneCall({
                phoneNumber: mobile
              })
            }
          }
        })
      }
    },
    callCustom() {
      this.call(this.noticeData.value2)
    }
  }
}
</script>

<style scoped>
.call_btn {
  background-color: #3070F6;
  color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 50%;
  padding: 20rpx;
  margin: 0 auto;
  border-radius: 50rpx;
  margin-top: 120rpx;
}
</style>